import request from '@/store/request'
// 获取列表信息
export function queryMember (page, size) {
  return request({
    url: 'member/list',
    method: 'get',
    dataType: 'json',
    data: {
      page: page,
      size: size
    }
  })
}
// 验证userId是否重复
export function findByUserId (userId) {
  return request({
    url: 'member/findByUserId/' + userId,
    method: 'get',
    dataType: 'josn'
  })
}
// 查询所有角色
export function findAllRoles () {
  return request({
    url: 'security/role/all',
    method: 'get',
    dataType: 'json'
  })
}

// 新增用户
export function insert (form) {
  return request({
    url: 'member/insert',
    method: 'post',
    dataType: 'josn',
    data: form
  })
}

// 查询用户的角色
export function memberRoles (id) {
  return request({
    url: 'member/roles/' + id,
    method: 'get',
    dataType: 'josn'
  })
}
// 修改用户状态
export function updateStatus (userId, status) {
  return request({
    url: 'member/update/status',
    method: 'post',
    dataType: 'json',
    data: {
      userId: userId,
      status: status
    }
  })
}

// 修改用户信息
export function update (form) {
  return request({
    url: 'member/update',
    method: 'POST',
    dataType: 'json',
    data: form
  })
}

// 重置密码
export function passwordReset (userId, password) {
  return request({
    url: 'member/password/reset',
    method: 'POST',
    dataType: 'json',
    data: {
      userId: userId,
      password: password
    }
  })
}

// 获取用户菜单
export function memberMenus () {
  return request({
    url: 'member/menus',
    method: 'GET',
    dataType: 'josn'
  })
}
// 获取用户权限
export function memberPermissions (userId) {
  return request({
    url: 'member/permission/' + userId,
    method: 'GET',
    dataType: 'josn'
  })
}
// 获取用户资源
export function memberResources (userId) {
  return request({
    url: 'member/resource/' + userId,
    method: 'GET',
    dataType: 'josn'
  })
}
// 通过手机号查询对象
export function getMemberAccountByMobile (mobile) {
  return request({
    url: 'member/exist/mobile/' + mobile,
    method: 'GET',
    dataType: 'josn'
  })
}
